/**
 * @Author 韦建韩
 * @Date 2022/3/29
 */
package com.example.devops.config;

import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
import org.apache.ibatis.reflection.MetaObject;
import org.springframework.stereotype.Component;


@Component
public class MyMetaObjectHandler implements MetaObjectHandler {
    @Override
    public void insertFill(MetaObject metaObject) {

        this.setFieldValByName("createTime", System.currentTimeMillis(), metaObject);

        this.setFieldValByName("updateTime", System.currentTimeMillis(), metaObject);


        this.setFieldValByName("deleted", 0, metaObject);

    }

    @Override
    public void updateFill(MetaObject metaObject) {
        if (getFieldValByName("updateTime", metaObject) != null) {
            this.setFieldValByName("updateTime", System.currentTimeMillis(), metaObject);
        }
    }
}
